<?php
  $content = '';
  if ($_POST['submitted']) {
      include('data/lib_f_validate.inc.php');
      if (!$text = validateText($_POST['text'])) $err = 'Invalid Text<br>';
      if (!$err) {
          if (mq("UPDATE contents SET ".$_SESSION['subtopic']."='$text' LIMIT 1")) {
            logevent('Update contents.');
            $content .= 'Saved successfully.<br>';
          }
      } else $content .= $err;
  } else $text = mqs("SELECT ".$_SESSION['subtopic']." FROM contents LIMIT 1");
  
  #include('data/lib_uccc_officers.inc.php'); '.show_officer_drop_down_list('text').'
  if ($_SESSION['logged'] & $_SESSION['rights'] & $r_webmaster) {
    include('data/lib_f_admin.inc.php');
    $content .= 'Please edit the text here:<br>
                <form action="'.$_SERVER['PHP_SELF'].'" method="POST">
                  <textarea name="text" rows="20" cols="64">'.DBToForm($text).'</textarea><br>
                  <input type="submit" class="button" value="submit">
                  <input type="hidden" name="submitted" value="1">
                </form>';  
  } else {
    $content = $text;
  }
?>
